package com.heima.utils.thread;

import com.xhh.model.user.pojos.User;

/**
 * @author:xhh
 * @email:3231954428@qq.com
 * @desc:
 * @datatime:2024/4/30 22:21
 */
public class ThreadLocalUtil {

    private static final ThreadLocal<User> APP_USER_THREAD_LOCAL = new ThreadLocal<>();

    /**
     * 添加用户
     * @param user
     */
    public static void setUser(User user){
        APP_USER_THREAD_LOCAL.set(user);
    }

    /**
     * 获取用户
     * @return
     */
    public static User getUser(){
        return APP_USER_THREAD_LOCAL.get();
    }

    /**
     * 移除用户信息
     */
    public static void clear(){
        APP_USER_THREAD_LOCAL.remove();
    }

}
